<div class="title">
  <div class='content'>
    <%= @install_item.status.after_serviced? ? '' : '编辑-'  %>售后服务
  </div>
  <div class='tools'>
    <%= link_to '返回',
          install_items_installation_url(@install_item.installation),
          :remote => true,
          :method => :get
     %>
  </div>
</div>
<%= form_for @install_item,
     :url => update_after_serviced_installation_url(@install_item),
     :remote => true,
     :method => :put do |f|
 %>
<div class='info'>
  <table>
    <tr>
      <th>
        款式：
      </th>
      <td>
        <%= @install_item.furniture.furniture_style.code %>-<%= @install_item.furniture.furniture_style.name %>
      </td>
    </tr>
    <tr>
      <th>
        材质：
      </th>
      <td>
        <%= @install_item.furniture.material.code %>-<%= @install_item.furniture.material.name %>
      </td>
    </tr>
    <tr>
      <th>
        规格：
      </th>
      <td>
        <%= @install_item.furniture.spec %>
      </td>
    </tr>
    <tr>
      <th>
        计划安装：
      </th>
      <td>
        <%= @install_item.has_been_sent_to_installer_count %>件
      </td>
    </tr>
    <tr>
      <th>
        完成安装：
      </th>
      <td>
        <b id='installed_count_b'><%= @install_item.installed_count %></b>件
      </td>
    </tr>
    <tr>
      <th>
        售后服务：
      </th>
      <td>        
        <%= link_to_function '-','',:id => "sub_after_serviced_count" %>
        <%= f.text_field :after_serviced_count, :readonly => true %>件
        <%= link_to_function '+','',:id => "add_after_serviced_count" %> 
        <script type="text/javascript" charset="utf-8">
          $(document).ready(function(){
          $('#add_after_serviced_count').click(function(){
            if($('#install_item_after_serviced_count').val() < <%= @install_item.has_been_sent_to_installer_count %> ) {
              $('#install_item_after_serviced_count').val(Number($('#install_item_after_serviced_count').val()) + 1);
              $('#installed_count_b').html(<%= @install_item.has_been_sent_to_installer_count %> - $('#install_item_after_serviced_count').val());
            }
          });
          $('#sub_after_serviced_count').click(function(){
            if($('#install_item_after_serviced_count').val() > 1 ) {
              $('#install_item_after_serviced_count').val(Number($('#install_item_after_serviced_count').val()) - 1);
              $('#installed_count_b').html(<%= @install_item.has_been_sent_to_installer_count %> - $('#install_item_after_serviced_count').val());
            }
          });
        });
        </script>
      </td>
    </tr>
    <tr>
      <th>备注：</th>
      <td colspan='3'>
        <%= f.text_area :remark, :rows => 6 %>
      </td>
    </tr>
    <tr>
      <td colspan='4' class='b'>
        <%= f.submit '保存', :class => :bb %>
        <%= link_to '返回',
              install_items_installation_url(@install_item.installation),
              :remote => true,
              :method => :get,
              :class => :bb
         %>
      </td>
    </tr>
  </table>
</div>
<% end %>